Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Attenuation and Fall-Off Values

Some lights suffer attenuation; that is, a loss of intensity over distance. The application determines the degree of attenuation of a light by specifying substituends for three distinct variables in a complex term that occurs in whatever formula it uses to compute the intensity of that light at a given distance from its source. The choice of constants determines whether the light suffers attenuation and, if so, the degree to which its intensity diminishes as a function of distance. These constants are specified in a data structure of the type described here.

Attenuation DataType

Float32             c0
Float32             c1
Float32             c2

Description

The attenuation factor determined by an attenuation data type is expressed by the result of replacing the variables c 0, c 1, c 2 by the values of the fields c0 , c1 , c2 in the complex term

(Here l is the location of the light source, p is the illuminated point, and dl, p is the distance from l to p .)

The initial intensity of a light is multiplied by its attenuation factor when the intensity of the light at a point is computed. Thus, if c 0 = 1 and c 1 = c 2 = 0, then the light does not suffer attenuation over distance. If c 1 = 1 and c 0 = c 2 = 0, then the intensity of the light at a point p diminishes in proportion to the distance between p and the light source, provided that that distance is at least one unit. If c 2 = 1 and c 0 = c 1 = 0, then the intensity of the light at p diminishes in proportion to the square of the distance between p and the light source, again provided that that distance is at least one unit. If c 0 = c 2 = 1 and c 1 = 0, then the intensity of the light at p diminishes in proportion to the sum of 1 and the square of the distance between p and the light source.

The attenuation factor is not clamped to a maximum value. Thus, for some choices of c 0, c 1, c 2, the intensity of a light may exceed its source intensity at distances of less than one unit, driving the RGB color values of the light toward the maximum of (1, 1, 1), or pure white.

The amount of illumination that a point illuminated by a light receives from that light also depends on several other factors. Among these factors are the diffuse and specular reflection characteristics of the surface that contains that point and the relative positions of the light source, the illuminated point, and the viewer (the camera).

Light Fall-Off Values

A spot light specifies a cone of light emanating from a source location. Within the inner cone defined by the hot angle of a spot light, the light may suffer attenuation over distance from the light source. Within the outer section of the cone between the hot angle and the outer angle of a spot light, the light may suffer further attenuation.

Spot lights have a fall-off value that determines the manner of attenuation of the light from the edge of the cone defined by the hot angle to the edge of the cone defined by the outer angle. The direction of fall off is perpendicular to the ray from the source location through the center of the cone. The amount of additional attenuation determined by any fall-off value is the same along all rays from the location of the light source forming the same angle with the axis of the cone.

The following constants specify four fall-off values a spot light may have.

FallOff VALUES

None                0x00000000
Linear              0x00000001
Exponential         0x00000002
Cosine              0x00000003

Constant descriptions

None
The intensity of the light is not affected by the distance from the center of the cone to the edge of the cone.
Linear
The intensity of the light at the edge of the cone falls off at a constant rate from the intensity of the light at the center of the cone.
Exponential
The intensity of the light at the edge of the cone falls off exponentially from the intensity of the light at the center of the cone.
Cosine
The intensity of the light at the edge of the cone falls off as the cosine of the outer angle from the intensity of the light at the center of the cone.

© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |